import node_fetch from 'node-fetch'

interface IField {
	column_name: string;
	column_comment: string;
}

export default function get_table(nodejs: string, sessionid, tables: string[]): Promise<IField[]> {
	return new Promise((resolve) => {
		node_fetch(nodejs + '/get-table', {
			method: 'POST',
			headers: {
				'Connection': 'Keep-Alive',
				'Content-Type': 'application/json',
				'Cookie': `sessionid=${sessionid}`
			},
			body: JSON.stringify({
				tables
			})
		}).then((res) => {
			return res.json()
		}).then((json) => {
			resolve(json)
		})
	})
}
